<template>
  <div class="table-toolbar">
    <div class="left">
      <slot name="left">
        <el-button type="primary" @click="$emit('add')">新增</el-button>
      </slot>
    </div>
    <div class="right">
      <slot name="right">
        <el-input
          v-model="searchValue"
          placeholder="请输入搜索内容"
          @input="handleSearch"
          clearable>
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TableToolbar',
  data() {
    return {
      searchValue: ''
    }
  },
  methods: {
    handleSearch(value) {
      this.$emit('search', value)
    }
  }
}
</script>

<style scoped>
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.right {
  display: flex;
  align-items: center;
}
.right .el-input {
  width: 200px;
  margin-left: 10px;
}
</style> 